<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			.mui-input-group label {
				width: 22%;
			}
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			.mui-content-padded {
				margin-top: 25px;
			}
			.mui-btn {
				padding: 10px;
			}
			
		</style>
		<!--common---start-->
		<script src="../js/angular/angular.min.js"></script>
		<script src="../js/angular/angular-resource.js"></script>
		<script src="../js/angular/common.js"></script>
		<!--common---end-->
		<script src="../js/mui.min.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/app.js"></script>
		<script src="../js/service/userService.js" ></script>
	</head>
	<body ng-app="mainApp" ng-controller="updatePwdCtrl" >
		<header class="mui-bar mui-bar-nav mui-bar-detail">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改密码</h1>
		</header>
		<div class="mui-content reg_con ">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>输入旧密码</label>
					<input id='password' name='password' ng-model="password"  type="password" class="mui-input-clear mui-input" placeholder="输入旧密码">
				</div>
				<div class="mui-input-row">
					<label>输入新密码</label>
					<input id='password_new' name='password_new' type="password" ng-model="password_new"  class="mui-input-clear mui-input" placeholder="输入新密码">
				</div>
				<div class="mui-input-row">
					<label>确认密码</label>
					<input id='password_confirm' name='password_confirm' type="password" ng-model="password_confirm"  class="mui-input-clear mui-input" placeholder="确认密码">
				</div>
			</form>
			<div class="mui-content-padded">
				<button  class="mui-btn mui-btn-block mui-btn-primary reg" ng-click="uploadPwd()">提交</button>
			</div>
		</div>
		
		<script>
			mainApp.controller('updatePwdCtrl', function($scope, $http,userService) {
				(function($, doc) {
					var password; 
					$.init();
					$.plusReady(function() {
						var users = JSON.parse(localStorage.getItem('$users') || '[]');
						
						users.some(function(user) {
							password= user.password;
						});
						
						
						$scope.uploadPwd=function(){
							if($scope.password!=password){
								mui.alert("输入的原密码不正确");
								return false;
							}
							if($scope.password_new!=$scope.password_confirm){
								mui.alert("两次密码不一样");
								return false;
							}
							userService.updateUserPwd($scope.password,$scope.password_confirm,function(data){
								if(data.status==1){
									mui.alert("密码修改成功");
								}else{
									mui.alert("密码修改失败");
								}
							},error)
						}
					});
					
					
				}(mui, document));
				
			});
		</script>
	</body>

</html>